package com.ruoyi.bizsys.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.bizsys.domain.AwardRecord;
import com.ruoyi.bizsys.mapper.AwardRecordMapper;
import com.ruoyi.bizsys.service.IAwardRecordService;
import org.springframework.stereotype.Service;

import java.util.Arrays;
import java.util.List;


/**
 * 奖励订单Service业务层处理
 *
 * @author african-loan
 * @date 2022-06-22
 */
@Service
public class AwardRecordServiceImpl extends ServiceImpl<AwardRecordMapper, AwardRecord> implements IAwardRecordService {

    /**
     * 查询奖励订单
     *
     * @param id 奖励订单ID
     * @return 奖励订单
     */
    @Override
    public AwardRecord selectAwardRecordById(Long id) {
        return this.getById(id);
    }

    /**
     * 查询奖励订单列表
     *
     * @param awardRecord 奖励订单
     * @return 奖励订单
     */
    @Override
    public List<AwardRecord> selectAwardRecordList(AwardRecord awardRecord) {
        return this.list(new QueryWrapper<>(awardRecord).last("order by id desc"));
    }

    /**
     * 新增奖励订单
     *
     * @param awardRecord 奖励订单
     * @return 结果
     */
    @Override
    public int insertAwardRecord(AwardRecord awardRecord) {
        awardRecord.setCreateTime(DateUtils.getNowDate());
        return baseMapper.insert(awardRecord);
    }

    /**
     * 修改奖励订单
     *
     * @param awardRecord 奖励订单
     * @return 结果
     */
    @Override
    public int updateAwardRecord(AwardRecord awardRecord) {
        awardRecord.setUpdateTime(DateUtils.getNowDate());
        return baseMapper.updateById(awardRecord);
    }

    /**
     * 批量删除奖励订单
     *
     * @param ids 需要删除的奖励订单ID
     * @return 结果
     */
    @Override
    public int deleteAwardRecordByIds(Long[] ids) {
        return baseMapper.deleteBatchIds(Arrays.asList(ids));
    }

    /**
     * 删除奖励订单信息
     *
     * @param id 奖励订单ID
     * @return 结果
     */
    @Override
    public int deleteAwardRecordById(Long id) {
        return baseMapper.deleteById(id);
    }

}
